﻿@model IEnumerable<LotteryVoteMVC.Models.CompanyAmountInfo>
@using LotteryVoteMVC.Core
@using LotteryVoteMVC.Resources
@{
    ViewBag.Title = Resource.LimitMonitor;
    Layout = "~/Views/Shared/Main.cshtml";
}
@section Header
{
    <link href="@Url.Content("~/Content/TableBase.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var showDetail = function (companyId, gpwId, name, gpw) {
            buildFrame("showDetail{0}{1}".format(companyId, gpwId), 600, 800, "/Limit/UpperMonitorDetail/{0}/{1}".format(companyId, gpwId), "{0} {1}".format(name, gpw), null, false, true);
        }
        $(document).ready(function () {
            $(".acceptControl :checkbox").change(function () {
                var infos = $(this).val().split("_");
                var url = "/Limit/StopAcceptBet/{0}/{1}".format(infos[0], infos[1]);
                visit(url);
            });
        });
    </script>
    <style type="text/css">
        table
        {
            width: 24%;
            float: left;
            margin-right: 5px;
        }
    </style>
}
<div id="searchBar">
    <input type="button" value="@Resource.Refresh" onclick="reloadPage();" />
</div>
@foreach (var item in Model)
{ 
    <table cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <td colspan="3">
                    @item.Company.Name
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    @item.CompanyBetAmount.ToString("N")
                </td>
            </tr>
        </thead>
        <tbody>
            @foreach (var gpwAmount in item.GamePlayWayBetAmount)
            {
                <tr>
                    <td>
                        @gpwAmount.Key.GetGPWDescription()
                    </td>
                    <td>
                        <span class="acceptControl">
                            <input id="@(item.Company.CompanyId)_@(gpwAmount.Key.Id)" value="@(item.Company.CompanyId)_@(gpwAmount.Key.Id)" type="checkbox" @(Extended.IsStopAcceptBet(item.Company.CompanyId, gpwAmount.Key.Id) ? "checked=checked" : string.Empty) />
                            <label for="@(item.Company.CompanyId)_@(gpwAmount.Key.Id)">
                                @Resource.Stop</label>
                        </span>
                    </td>
                    <td style="text-align: left">
                        <a href='javascript:showDetail(@item.Company.CompanyId,@gpwAmount.Key.Id,"@item.Company.Name","@gpwAmount.Key.GetGPWDescription()")'>@gpwAmount.Value.ToString("N")</a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
}